/**
 * Created with IntelliJ IDEA.
 * Description:
 * https://gitee.com/li--jiaqiang/java-test.git
 * git pull
 * git pull origin master
 * git pull origin master --allow-unrelated-histories
 * User: 86187
 * Date: 2022-04-23
 * Time: 11:01
 */

//Scanner scan = new Scanner(System.in);

import java.util.Scanner;

public class TestArray2 {

    /**
     * 数组中有两个数只出现一次，其他数出现两次
     * 找出这两个数
     * @param array
     */
    public static void search(int[] array) {
        int ret = 0;
        int k = 0;
        int m = 0;
        int n = 0;
        for (int i = 0; i < array.length; i++) {
            ret ^= array[i];
        }
        for (int i = 0; i < 32; i++) { //0000 0110  6
                                       //0000 0100  4
            //                         //0000 0010  2
            if(((ret >> i) & 1) == 1) {
                k = i;
                break;
            }
        }
        for (int i = 0; i < array.length; i++) {
            if(((array[i] >> k) & 1) ==  1)
            {
                m ^= array[i];
            }
            else {
                n ^= array[i];
            }
        }
        System.out.println(m);
        System.out.println(n);
    }

    public static void main(String[] args) {
        int[] array = {1,3,5,7,6,9,7,3,5,1};

        search(array);
    }
}
